package org.NooLab.structures.randomgraph;

import java.util.ArrayList;



/**
 * 
 * is used for words, sentences, paragraphs and pages
 * 
 * 
 *
 */
public class RawEntityPositions {

	ArrayList<RawEntityPosition>  items = new ArrayList<RawEntityPosition>() ;
	
	// ------------------------------------------------------------------------
	public RawEntityPositions(){
		
	}
	// ------------------------------------------------------------------------
	
	public void clear() {
		items.clear();
	}

	public ArrayList<RawEntityPosition> getItems(){
		return items;
	}

	public RawEntityPosition getItem( int index){
		RawEntityPosition item=null;
		if ((index>=0) && (index<items.size())){
			item = items.get(index);
		}
		return item;
	}

	public int size() {
		return items.size();
	}

	public String getConcatenatedParts(int first, int last) {
		return getConcatenatedParts( first, last, " ") ;
	}
	public String getConcatenatedParts(int first, int last, String separator) {
		String ccStr = "";
		
		if (last>items.size()-1){
			last =items.size()-1;
		}
		if (first>last){
			return "";
		}
		if ((first<0) || (last>items.size()-1)){
			return "";
		}
		if (first==last){
			return items.get(first).getTextualStr();
		}
		for (int i=first;i<=last;i++){
			ccStr = ccStr + items.get(i).textualStr;
			if (i<last){
				ccStr=ccStr+ separator;
			}
		}
		return ccStr;
	}

}
